/*
 * @Author: 李灿
 * @Date: 2020-10-29 14:26:44
 * @LastEditTime: 2021-07-28 18:49:08
 * @Description:词法作用域
 * @FilePath: /javascript/meetings/2.词法作用域/index.js
 */
// 词法作用域在定义的时候就会确定了
var value = 1;

function foo() {
  console.log(value);
}

function bar() {
  var value = 2;
  foo();
}

bar(); // 1

var scope = "global scope";
function checkscope() {
  var scope = "local scope";
  function f() {
    return scope;
  }
  return f();
}
checkscope(); // local scope 就近原则
var scope = "global scope";
function checkscope() {
  var scope = "local scope";
  function f() {
    return scope;
  }
  return f;
}
checkscope()(); // local scope 就近原则
